package com.ruoyi.cloudpc.controller;

import com.ruoyi.cloudpc.domain.CloudSupportCenter;
import com.ruoyi.cloudpc.service.ICloudSupportCenterService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 帮助中心Controller
 *
 * @author Ten
 * @date 2025-09-28
 */
@RestController
@RequestMapping("/cloudpc/surpportcenter")
public class CloudSupportCenterController extends BaseController {
    @Autowired
    private ICloudSupportCenterService cloudSupportCenterService;

    /**
     * 查询帮助中心列表
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:list')")
    @GetMapping("/list")
    public TableDataInfo list(CloudSupportCenter cloudSupportCenter) {
        startPage();
        List<CloudSupportCenter> list = cloudSupportCenterService.selectCloudSupportCenterList(cloudSupportCenter);
        return getDataTable(list);
    }

    /**
     * 导出帮助中心列表
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:export')")
    @Log(title = "帮助中心", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CloudSupportCenter cloudSupportCenter) {
        List<CloudSupportCenter> list = cloudSupportCenterService.selectCloudSupportCenterList(cloudSupportCenter);
        ExcelUtil<CloudSupportCenter> util = new ExcelUtil<CloudSupportCenter>(CloudSupportCenter.class);
        util.exportExcel(response, list, "帮助中心数据");
    }

    /**
     * 获取帮助中心详细信息
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(cloudSupportCenterService.selectCloudSupportCenterById(id));
    }

    /**
     * 新增帮助中心
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:add')")
    @Log(title = "帮助中心", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CloudSupportCenter cloudSupportCenter) {
        return toAjax(cloudSupportCenterService.insertCloudSupportCenter(cloudSupportCenter));
    }

    /**
     * 修改帮助中心
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:edit')")
    @Log(title = "帮助中心", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CloudSupportCenter cloudSupportCenter) {
        return toAjax(cloudSupportCenterService.updateCloudSupportCenter(cloudSupportCenter));
    }

    /**
     * 删除帮助中心
     */
//    @PreAuthorize("@ss.hasPermi('cloudpc:surpportcenter:remove')")
    @Log(title = "帮助中心", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(cloudSupportCenterService.deleteCloudSupportCenterByIds(ids));
    }
}
